package com.goodving.guli.server;

import android.content.Context;
import android.content.Intent;

import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.view.C3657a;

import org.json.JSONException;
import org.json.JSONObject;

import cn.com.smartdevices.bracelet.config.C0886a;

/* renamed from: cn.com.smartdevices.bracelet.j.n */
public class WebResponse { // C1331n
    public static final int f6822a = -1;
    public static final int f6823b = 0;
    public static final int f6824c = 1;
    public static final int f6825d = 2;
    public static final int f6826e = 666;
    public static final int f6827f = 50001;
    public static final int f6828g = 50018;
    public int f6829h;
    public String f6830i;

    public WebResponse() {
        this.f6829h = f6822a;
        this.f6830i = C3657a.f18328f;
    }

    public static WebResponse getWebResponse(Context context, String str) { // m11654a
        try {
            return WebResponse.getWebResponse(context, new JSONObject(str));
        } catch (JSONException e) {
            WebResponse c1331n = new WebResponse();
            c1331n.f6829h = f6825d;
            return c1331n;
        }
    }

    public static WebResponse getWebResponse(Context context, JSONObject jSONObject) { // m11655a
        GuliLog.tracePrintInfo("WebResponse", "getWebResponse:" + jSONObject.toString());
        WebResponse c1331n = new WebResponse();
        try {
            c1331n.f6829h = jSONObject.getInt("code");
            c1331n.f6830i = jSONObject.getString("message");
        } catch (JSONException e) {
            c1331n.f6829h = f6825d;
            GuliLog.tracePrintInfo("WebResponse", "getWebResponse:" + jSONObject.toString());
            GuliLog.tracePrintInfo(C0668a.cc, "ws.code = " + c1331n.f6829h + ", ws.message = " + c1331n.f6830i);
        }
        if (c1331n.m11658b() && C0886a.m9071f(context).isValid()) {
            GuliLog.m12370d(C0668a.cc, "start login activity, ws = " + c1331n);
            WebResponse.m11656a(context);
        }
        return c1331n;
    }

    private static void m11656a(Context context) {
        Intent intent = new Intent("cn.com.smartdevices.bracelet.intent.action.LOGIN");
        intent.setFlags(805339136);
        try {
            context.startActivity(intent);
        } catch (Exception e) {
            try {
                Intent intent2 = new Intent(context, Class.forName("cn.com.smartdevices.bracelet.activity.LoginActivity"));
                intent2.setFlags(805339136);
                context.startActivity(intent2);
            } catch (ClassNotFoundException e2) {
                throw new IllegalStateException("cn.com.smartdevices.bracelet.intent.action.LOGIN not exised");
            }
        }
        C0886a.m9063a(context, -1, null);
    }

    public boolean m11657a() {
        return this.f6829h == f6827f;
    }

    public boolean m11658b() {
        return this.f6829h == 0;
    }

    public boolean m11659c() {
        return this.f6829h == f6824c;
    }

    public boolean equals(Object obj) {
        return ((WebResponse) obj).f6829h == this.f6829h;
    }
}
